﻿/**
 *	@file		CCGemetry.h
 *	@author		NeoZhang
 *	@version	v0.1
 *	@date		2013/09/03
 *	@brief		几何(坐标、尺寸、矩形)处理定义
 */

#ifndef __CC_GEOMETRY_H__
#define __CC_GEOMETRY_H__

//!	自定义宏
#include "platform\CCPlatformMacros.h"

//!	命名空间
NS_CC_BEGIN

//!	坐标处理类
class CC_DLL CCPoint
{
public:
	//!	x坐标
	float x;
	//!	y坐标
	float y;

public:
	CCPoint();
	CCPoint(float x, float y);
	CCPoint(const CCPoint& other);
	CCPoint& operator = (const CCPoint& other);
	void setPoint(float x, float y);
	bool equals(const CCPoint& target) const;
};

//! 尺寸处理类
class CC_DLL CCSize
{
public:
	//!	宽
	float width;
	//!	高
	float height;

public:
	CCSize();
	CCSize(float width, float height);
	CCSize(const CCSize& other);
	CCSize& operator= (const CCSize& other);
	void setSize(float width, float height);
	bool equals(const CCSize& target) const;
};

//!	矩形处理类
class CC_DLL CCRect
{
public:
	//!	原点
	CCPoint origin;
	//!	尺寸
	CCSize	size;

public:
	CCRect();    
    CCRect(float x, float y, float width, float height);
    CCRect(const CCRect& other);
    CCRect& operator= (const CCRect& other); 
    void setRect(float x, float y, float width, float height);
	//!	获取x坐标最小值
    float getMinX() const; 
	//!	获取x坐标中间值
    float getMidX() const;
	//!	获取x坐标最大值
    float getMaxX() const;
	//! 获取y坐标最小值
    float getMinY() const;
	//!	获取y坐标中间值
    float getMidY() const;
	//!	获取y坐标最大值
    float getMaxY() const;
    bool equals(const CCRect& rect) const;   
    bool containsPoint(const CCPoint& point) const;
    bool intersectsRect(const CCRect& rect) const;
};

//!	定义坐标处理宏
#define CCPointMake(x, y)					CCPoint((float)(x), (float)(y))
//!	定义尺寸处理宏
#define	CCSizeMake(width, height)			CCSize((float)(width), (float)(height))
//!	定义矩形处理宏
#define CCRectMake(x, y, width, height)		CCRect((float)(x), (float)(y), float(width), float(height))

//!	定义0坐标
const CCPoint CCPointZero = CCPointMake(0,0);
//!	定义0尺寸
const CCSize CCSizeZero = CCSizeMake(0, 0);
//! 定义原点坐标
const CCRect CCRectZero = CCRectMake(0, 0, 0, 0);

NS_CC_END

#endif